<template>
	<div class="content">
		<div style="margin-bottom: 10px;">
			<Select placeholder="请选归集币种" class="w200 m-r10" v-model="state" @on-change="coinChange">
				<Option value="1">EXUU</Option>
				<Option value="2">USDT</Option>
			</Select>
			<Checkbox v-model="single" @on-change="checkChange">自动归集</Checkbox>
			<i-button type="primary" @click="collection" :disabled="single">手动归集</i-button>
		</div>
		<Table stripe :columns="columns1" :data="list" :loading="loading"></Table>
		<Page :total="info" show-elevator :page-size="pageSize" show-total @on-change="changepage" :current.sync="current"></Page>
	</div>
</template>
<script>
	export default {
		data() {
			return {
				single: false,
				loading: false,
				columns1: [{
					title: "币种名称",
					align: "center",
					key: "coin_name",
					render: (h, params) => {
						return h("div", params.row.coin_name == null ? "#" : params.row.coin_name);
					}
				}, {
					title: "归集数量",
					align: "center",
					key: "num",
					render: (h, params) => {
						return h("div", params.row.num == null ? "#" : params.row.num);
					}
				}, {
					title: "手续费",
					align: "center",
					key: "fee",
					render: (h, params) => {
						return h("div", params.row.fee == null ? "#" : params.row.fee);
					}
				}, {
					title: "转出地址",
					align: "center",
					key: "form_address",
					render: (h, params) => {
						return h("div", params.row.form_address == null ? "#" : params.row.form_address);
					}
				}, {
					title: "到账地址",
					align: "center",
					key: "to_address",
					render: (h, params) => {
						return h("div", params.row.to_address == null ? "#" : params.row.to_address);
					}
				}, {
					title: "转账时间",
					align: "center",
					key: "transfer_time",
					render: (h, params) => {
						return h("div", params.row.transfer_time == null ? "#" : this.stringToTime(params.row.transfer_time));
					}
				}, {
					title: "状态",
					align: "center",
					key: "status_id",
					render: (h, params) => {
						return h("div", params.row.status_id == null ? "#" : params.row.status_id == 1 ? '成功' : params.row.status_id == 2 ? '失败' : params.row.status_id == 3 ? '转账中' : params.row.status_id == 4 ? '数据收集' : '#');
					}
				}, {
					title: "交易txId",
					align: "center",
					key: "tx_id",
					render: (h, params) => {
						return h("div", params.row.tx_id == null ? "#" : params.row.tx_id);
					}
				}],
				list: [],
				check: '',
				info: 0,
				pageSize: 20,
				current: 1,
				state: '1',
			};
		},
		methods: {
			checkChange() {
				this.axios.put('/admin/collect/collect/setAutoCollect', this.qs.stringify({
					coinId: this.state,
					autoCollect: this.check
				})).then(res => {
					if(res.data.code == 200) {
						this.$Message.info(res.data.msg);
					}
				})
			},
			collection() {
				this.axios.get('/admin/collect/collect/excuse/' + this.state).then(res => {
					if(res.data.code == 200) {
						this.$Message.info(res.data.msg);
					}
				})
			},
			getList() {
				this.axios.get('/admin/collect/collect/info', {
					params: {
						current: this.current,
						size: this.pageSize,
					}
				}).then(res => {
					if(res.data.code == 200) {
						this.list = res.data.data.records;
						this.info = res.data.data.total;
					}
				})
			},
			changepage(page) {
				this.axios.get('/admin/collect/collect/info', {
					params: {
						current: page,
						size: this.pageSize,
					}
				}).then(res => {
					if(res.data.code == 200) {
						this.list = res.data.data.records;
					}
				})
			},
			extract() {
				this.axios.post('/admin/collect/collect/trade', this.qs.stringify({
					coinId: 0,
					amount: this.addForm.amount,
					password: this.addForm.pass
				})).then(res => {
					if(res.data.code == 200) {
						this.getList();
						this.getAddress();
						this.$Message.info(res.data.msg);
						this.modal = fales;
					}
				})
			},
			coinChange(e) {
				this.state = e;
				this.axios.get('/admin/collect/collect/autoCollect/' + this.state).then(res => {
					if(res.data.code == 200) {
						this.single = res.data.data;
						this.check = res.data.data;
					}
				})
			}
		},
		created() {},
		mounted() {
			this.axios.get('/admin/collect/collect/autoCollect/' + this.state).then(res => {
				if(res.data.code == 200) {
					this.single = res.data.data;
					this.check = res.data.data;
				}
			})
			this.getList();
		},
	};
</script>
<style lang="less">
	.ivu-modal-header {
		padding: 10px 16px;
		background-color: #f8f8f8;
		line-height: 1;
	}
	
	.tishi {
		color: red;
		margin-left: 10px;
		display: inline-block;
	}
</style>